package com.asset.salesforce.dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.asset.salesforce.domain.LogicalOperators;


@Repository
public class LogicalOperatorsDaoImpl {
	@Autowired
	SessionFactory sessionFactory;

	@SuppressWarnings("unchecked")
	public List<LogicalOperators> listOperators() {

		return sessionFactory.getCurrentSession().createQuery("from LogicalOperators")
				.list();
	}
	
	public LogicalOperators getLogicalOperatorById(Integer Id){
		Session session = sessionFactory.getCurrentSession();
		Query query = session.createQuery("from LogicalOperators where  id = :Id");
		query.setParameter("Id", Id);
		@SuppressWarnings("unchecked")
		List<LogicalOperators>  logicalOperators= query.list();
		System.out.println("><><><><><><+++++++++++++++++++++++++++++"+logicalOperators.size());
		if(logicalOperators.size() > 0)
		return logicalOperators.get(0);
		else
		return null;
	}
	
}
